var util = require('./util.js');

var wxUtil = {
  // 调用微信支付接口
  wxPay: function (param) {
    var _this = this;
    wx.requestPayment({
      'timeStamp': param.timeStamp,
      'nonceStr': param.nonceStr,
      'package': param.package,
      'signType': 'MD5',
      'paySign': param.paySign,
      success: function (res) {
        typeof param.success === 'function' && param.success();
        _this.wxPaySuccess(param);
      },
      fail: function (res) {
        if (res.errMsg === 'requestPayment:fail cancel' ||'requestPayment:fail') {
          return;
        }
        util.alert(res.errMsg)
        _this.wxPayFail(param, res.errMsg);
      }
    })
  },
  wxPaySuccess: function (param) {
  },
  wxPayFail: function (param, errMsg) {
  },
};

module.exports = wxUtil;